package com.itheima.wms.controller;

import com.itheima.pinda.base.BaseController;
import com.itheima.pinda.base.R;
import com.itheima.wms.factory.CodeFactory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * 编号工厂
 * </p>
 */
@Slf4j
@RestController
@RequestMapping("/codeFactory")
@Api(value = "CodeFactory", tags = "编号工厂")
public class CodeFactoryController extends BaseController {

    @Autowired
    private CodeFactory codeFactory;

    /**
     * 获取下一个对象
     *
     * @param name
     * @return 查询结果
     */
    @ApiOperation(value = "获取下一个编码", notes = "获取下一个编码")
    @GetMapping("/next/{name}")
    public R<String> get(@PathVariable String name) {
        return success(codeFactory.nextCode(name));
    }
}
